package com.ruoyi.pms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.pms.domain.DetailText2;
import com.ruoyi.pms.service.IDetailText2Service;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 富文本测试2Controller
 * 
 * @author yf
 * @date 2022-02-15
 */
@RestController
@RequestMapping("/text2")
public class DetailText2Controller extends BaseController
{
    @Autowired
    private IDetailText2Service detailText2Service;

    /**
     * 查询富文本测试2列表
     */
    @RequiresPermissions("pms:text2:list")
    @GetMapping("/list")
    public TableDataInfo list(DetailText2 detailText2)
    {
        startPage();
        List<DetailText2> list = detailText2Service.selectDetailText2List(detailText2);
        return getDataTable(list);
    }

    /**
     * 导出富文本测试2列表
     */
    @RequiresPermissions("pms:text2:export")
    @Log(title = "富文本测试2", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DetailText2 detailText2)
    {
        List<DetailText2> list = detailText2Service.selectDetailText2List(detailText2);
        ExcelUtil<DetailText2> util = new ExcelUtil<DetailText2>(DetailText2.class);
        util.exportExcel(response, list, "富文本测试2数据");
    }

    /**
     * 获取富文本测试2详细信息
     */
    @RequiresPermissions("pms:text2:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(detailText2Service.selectDetailText2ById(id));
    }

    /**
     * 新增富文本测试2
     */
    @RequiresPermissions("pms:text2:add")
    @Log(title = "富文本测试2", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DetailText2 detailText2)
    {
        return toAjax(detailText2Service.insertDetailText2(detailText2));
    }

    /**
     * 修改富文本测试2
     */
    @RequiresPermissions("pms:text2:edit")
    @Log(title = "富文本测试2", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DetailText2 detailText2)
    {
        return toAjax(detailText2Service.updateDetailText2(detailText2));
    }

    /**
     * 删除富文本测试2
     */
    @RequiresPermissions("pms:text2:remove")
    @Log(title = "富文本测试2", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(detailText2Service.deleteDetailText2ByIds(ids));
    }
}
